package com.motu.monstercity.server.game.logic;

import com.motu.monstercity.server.game.userdata.*;
import com.motu.vertx.module.utility.model.EntityManager;
import com.motu.vertx.module.utility.model.Model;

import java.util.ArrayList;
import java.util.List;

public class BuddyUserData extends BuddyBaseData {
    public static UserBuddy getUserBuddy(long userId,long buddyId) {
        return (UserBuddy) EntityManager.getEntity(UserBuddy.class, userId,buddyId);
    }

    // 获取UserBuddy列表
    public static List<UserBuddy> getUserBuddyList(long userId) {
        List<UserBuddy> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserBuddy.class, userId)) {
            UserBuddy entity = (UserBuddy) model;
            list.add(entity);
        }
        return list;
    }

    public static List<Long> getBuddyUserIdList(long userId){
        List<Long> uidList = new ArrayList<>();
        List<UserBuddy> list = BuddyManager.getUserBuddyList(userId);
        for (UserBuddy userBuddy : list) {
            uidList.add(userBuddy.getBuddyId());
        }
        return uidList;
    }

    
    public static long getUserBuddyCount(long userId) {
        return EntityManager.getEntityCount(UserBuddy.class, userId);
    }

    public static UserBuddyBlack getUserBuddyBlack(long userId, long blackid) {
        return (UserBuddyBlack) EntityManager.getEntity(UserBuddyBlack.class, userId, blackid);
    }

    public static List<UserBuddyBlack> getUserBuddyBlackList(long userId) {
        List<UserBuddyBlack> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserBuddyBlack.class, userId)) {
            UserBuddyBlack entity = (UserBuddyBlack) model;
            list.add(entity);
        }
        return list;
    }

    /**
     * 获取黑名单用户ID列表
     */
    public static List<Long> getBlackUserIdList(long userId) {
        List<Long> uidList = new ArrayList<>();
        List<UserBuddyBlack> list = BuddyManager.getUserBuddyBlackList(userId);
        for (UserBuddyBlack userBuddyBlack : list) {
            uidList.add(userBuddyBlack.getBlackId());
        }
        return uidList;
    }


    public static UserBuddyApply getUserBuddyApply(long userId, long appid) {
        return (UserBuddyApply) EntityManager.getEntity(UserBuddyApply.class, userId, appid);
    }

    public static List<UserBuddyApply> getUserBuddyApplyList(long userId) {
        List<UserBuddyApply> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserBuddyApply.class, userId)) {
            UserBuddyApply entity = (UserBuddyApply) model;
            list.add(entity);
        }
        return list;
    }

    public static long getUserBuddyApplyCount(long userId) {
        return EntityManager.getEntityCount(UserBuddyApply.class, userId);
    }

    public static UserBuddyApplyInfo getUserBuddyApplyInfo(long userId) {
        return (UserBuddyApplyInfo) EntityManager.getUniqueEntity(UserBuddyApplyInfo.class, userId);
    }

}
